" AST详细输出功能演示
" 这个文件展示了各种VimL语言特性及其AST分析

" 1. 简单变量声明
let x = 42
let name = "VimL"

" 2. 复杂表达式
let result = (1 + 2) * 3 - 4 / 2

" 3. 列表和字典
let numbers = [1, 2, 3, 4, 5]
let config = {"debug": 1, "verbose": 0}

" 4. 函数定义
function Sum(a, b)
    return a + b
endfunction

" 5. 条件语句
function IsPositive(n)
    if n > 0
        return 1
    else
        return 0
    endif
endfunction

" 6. 循环
function Factorial(n)
    let result = 1
    let i = 1
    while i <= n
        let result = result * i
        let i = i + 1
    endwhile
    return result
endfunction

" 7. 递归函数
function Fibonacci(n)
    if n <= 1
        return n
    else
        return Fibonacci(n-1) + Fibonacci(n-2)
    endif
endfunction

" 8. 复杂嵌套
function ProcessData(data)
    let results = []
    for item in data
        if item > 0
            let processed = item * 2
            call add(results, processed)
        endif
    endfor
    return results
endfunction

" 9. 函数调用
let sum_result = Sum(10, 20)
let fib_10 = Fibonacci(10)
let fact_5 = Factorial(5)

" 10. Echo输出
echo "Sum: " . sum_result
echo "Fibonacci(10): " . fib_10
echo "Factorial(5): " . fact_5